{extend name="layouts/app"/}
{block name="main"}
<style>
    .layui-table tbody tr:hover{background: none}
    .layui-input{display:inline-block}
    .input110{width:110px;}
    .input210{width:210px}
    dl.fieldlist{}
    dl.fieldlist dt{}
    dl.fieldlist dt span{display:inline-block;width:110px}
    dl.fieldlist dd{margin-top:10px}
</style>
<div class="layui-card">
    <div class="layui-card-header">系统配置</div>
    <div class="layui-card-body">
        <div class="layui-tab">
            <ul class="layui-tab-title">
                {volist name="$config_group->arrayValue" id="value"}
                    <li {eq name="$i" value="1"}class='layui-this'{/eq} >{$value}</li>
                {/volist}
            </ul>
            <div class="layui-tab-content">
                {volist name="$data" id="tab"}
                    <div class="layui-tab-item {eq name='$i' value='1'}layui-show{/eq}"  >
                        <form class="layui-form" method="post" action="{:url('update')}">
                        {volist name="$tab" id="row"}
                            {switch $row->type}
                            {case string }
                            <table class="layui-table setting-table" lay-even="" lay-skin="nob">
                                <colgroup>
                                    <col width="15%">
                                    <col width="70%">
                                    <col width="15%">
                                </colgroup>
                                <thead>
                                <tr>
                                    <th>变量标题</th>
                                    <th>变量值</th>
                                    <th>变量名</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr>
                                    <td>{$row->title}</td>
                                    <td>
                                        <input type="text" name="{$row->key}" value="{$row->value}" lay-verify="required" autocomplete="off" placeholder="{$row->title}" class="layui-input">
                                    </td>
                                    <td>{${$row->key}}</td>
                                </tr>
                                </tbody>
                            </table>
                            {/case}
                            {case array}
                            <table class="layui-table setting-table" lay-even="" lay-skin="nob">
                                <colgroup>
                                    <col width="15%">
                                    <col width="70%">
                                    <col width="15%">
                                </colgroup>
                                <thead>
                                <tr>
                                    <th>变量标题</th>
                                    <th>变量值</th>
                                    <th>变量名</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr>
                                    <td>{$row->title}</td>
                                    <td>
                                        <div class="">
                                            <dl class="fieldlist">
                                                <dt>
                                                    <span>键名</span>
                                                    <span>键值</span>
                                                </dt>
                                                {foreach $row->arrayValue as $key=>$value}
                                                <dd class="layui-form-item">
                                                    <input  type="text" name="{$row->key}[key][]" value="{$key}"  class="layui-input input110">
                                                    <input  type="text" name="{$row->key}[value][]" value="{$value}"  class="layui-input input210">
                                                    <a href="javascript:;" onclick="del(this)" class="layui-btn layui-btn-sm"><i class="layui-icon"></i></a>
                                                </dd>
                                                {/foreach}
                                                <dd><a href="javascript:;" data-name="{$row->key}" onclick="addItem(this)" class="layui-btn layui-btn-sm">追加</a></dd>
                                            </dl>
                                        </div>
                                    </td>
                                    <td>{${$row->key}}</td>
                                </tr>
                                </tbody>
                            </table>
                            {/case}
                                {default /}
                                    默认情况，正常情况不会出现。
                            {/switch}

                        {/volist}
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="formSubmit">立即提交</button>
                                <button class="layui-btn layui-btn-normal" type="button" onclick="javascript:history.back(-1);">返回</button>
                            </div>
                        </div>
                        </form>
                    </div>
                {/volist}

            </div>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    function del(obj) {
        $(obj).parent(".layui-form-item").remove();
    }
    function addItem(obj) {
        var $p=$(obj).parent("dd");
        var name = $(obj).data("name");
        var _html=' <dd class="layui-form-item">\n' +
            '<input  type="text" name='+name+'[key][]"  class="layui-input input110">\n' +
            '<input  type="text" name='+name+'[value][]"  class="layui-input input210">\n' +
            '<a href="javascript:;" onclick="del(this)" class="layui-btn layui-btn-sm"><i class="layui-icon"></i></a>\n' +
            '</dd>';
        $p.before(_html);
        layui.use(['form','jquery'],function () {
            var form=layui.form
                ,$=layui.jquery;
              form.render();
        });
    }
</script>
{/block}